#ifndef PATHMANAGER_H
#define PATHMANAGER_H

#include <QString>
#include <QDir>
#include <QStandardPaths>
#include <QCoreApplication>

/**
 * 跨平台路径管理器
 *
 * 遵循各操作系统推荐的目录规范：
 *
 * Windows:
 * - 配置文件: %APPDATA%/LongImageReader/
 * - 缓存文件: %LOCALAPPDATA%/LongImageReader/Cache/
 * - 日志文件: %APPDATA%/LongImageReader/Logs/
 * - 临时文件: %LOCALAPPDATA%/LongImageReader/Temp/
 * - 导出文件: %USERPROFILE%/Documents/
 *
 * macOS:
 * - 配置文件: ~/Library/Application Support/LongImageReader/
 * - 缓存文件: ~/Library/Caches/com.limereader.longimagereader/
 * - 日志文件: ~/Library/Logs/LongImageReader/
 * - 临时文件: /tmp/LongImageReader/
 * - 导出文件: ~/Documents/
 */
class PathManager
{
public:
    // 应用基本信息
    static QString getApplicationName();
    static QString getOrganizationName();
    static QString getApplicationDisplayName();

    // === 配置文件路径 ===
    // Windows: %APPDATA%/LongImageReader/
    // macOS: ~/Library/Application Support/LongImageReader/
    static QString getConfigDirectory();
    static QString getSettingsFilePath();

    // === 缓存文件路径 ===
    // Windows: %LOCALAPPDATA%/LongImageReader/Cache/
    // macOS: ~/Library/Caches/com.limereader.longimagereader/
    static QString getCacheDirectory();
    static QString getTempCacheDirectory();
    static QString getImageCacheDirectory();
    static QString getThumbnailCacheDirectory();

    // === 日志文件路径 ===
    // Windows: %APPDATA%/LongImageReader/Logs/
    // macOS: ~/Library/Logs/LongImageReader/
    static QString getLogDirectory();
    static QString getDebugLogPath();
    static QString getCrashLogDirectory();

    // === 临时文件路径 ===
    // Windows: %LOCALAPPDATA%/LongImageReader/Temp/
    // macOS: /tmp/LongImageReader/
    static QString getTempDirectory();
    static QString getTempFilePath(const QString& filename);

    // === 导出文件路径 ===
    // Windows: %USERPROFILE%/Documents/
    // macOS: ~/Documents/
    static QString getDocumentsDirectory();
    static QString getDefaultExportDirectory();
    static QString getPdfExportDirectory();

    // === 用户数据路径 ===
    // 用于用户创建的数据文件、书签等
    static QString getUserDataDirectory();
    static QString getBookmarksFilePath();
    static QString getRecentFilesPath();

    // === 应用程序路径 ===
    static QString getApplicationDirectory();
    static QString getExecutablePath();

    // === 工具方法 ===
    static bool ensureDirectoryExists(const QString& path);
    static QString cleanPath(const QString& path);
    static bool isPortableMode();
    static QString getPortableConfigDirectory();

    // === 调试信息 ===
    static void logAllPaths();
    static QString getPlatformInfo();
};

#endif // PATHMANAGER_H